package java56_5;

public class Student {
	private String name;
	private String sex;
	private int age;

	public Student() {
		// name = "无名";
		// sex = "保密";
		// age = 0;
		this("无名", "保密", 0);
	}

	public Student(String n, String s, int age) {
		name = n;
		sex = s;
		// this.age = age;
		this.setAge(age);
		// this.selfIntro();
	}

	// 修改属性的方法有个基本的命名规则
	public void setAge(int a) {// 年龄必须大于等于20，不合适，改成20
		if (a < 20) {
			System.out.println("年龄设置错误，已经改成了默认的20岁");
			a = 20;
		}
		this.age = a;
	}

	public int getAge() {
		return age;
	}

	public void setName(String n) {
		this.name = n;
	}

	public String getName() {
		return name;
	}

	public void setSex(String s) {
		// 限制性别
		this.sex = s;
	}

	public void selfIntro() {
		String s = "姓名";
		// String s = "姓名";
		System.out.println("姓名" + name + "," + sex + ",年龄" + age + ",至今未婚");
	}
}
